package ifpb.banco.entity;

import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Vanderlan
 */
@Entity
@Table(catalog = "", schema = "VANDERLAN")
@SequenceGenerator(name = "S_SERVICO_PK", sequenceName = "S_SERVICO_PK")
public class Servico extends Identificavel {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @Column(name = "COD_SERVICO", nullable = false, precision = 0, scale = -127)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_SERVICO_PK")
    protected Long id;
    @Basic(optional = false)
    @Column(nullable = false, length = 60)
    private String descricao;
    @Basic(optional = false)
    @Column(nullable = false, precision = 10, scale = 2)
    private BigDecimal valor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codServico")
    private Collection<ServicoSolicitado> servicoSolicitadoCollection;

    public Servico() {
    }

    public Servico(Long codServico) {
        this.id = codServico;
    }

    public Servico(Long codServico, String descricao, BigDecimal valor) {
        this.id = codServico;
        this.descricao = descricao;
        this.valor = valor;
    }

    public Long getCodServico() {
        return id;
    }

    public void setCodServico(Long codServico) {
        this.id = codServico;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public Collection<ServicoSolicitado> getServicoSolicitadoCollection() {
        return servicoSolicitadoCollection;
    }

    public void setServicoSolicitadoCollection(Collection<ServicoSolicitado> servicoSolicitadoCollection) {
        this.servicoSolicitadoCollection = servicoSolicitadoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Servico)) {
            return false;
        }
        Servico other = (Servico) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ifpb.banco.principal.entity.Servico[ codServico=" + id + " ]";
    }
    
}
